<?php
class SystempagesModel extends Model {
	//复制数据
	public function copy($siteid, $tositeid,$map){
		$re=$this->where($map)->select();
		if($re!==false){
			foreach($re as $k=>$v){
				$v['relate_id'] = $v['id'];
				$v['site_id'] = $tositeid;
				//设置页面ID到风格
				$v['page_view_id'] = (int)M('Pages') -> where(array('site_id' =>$tositeid, 'rid' => $v['page_view_id'])) -> getField('id');
				$v['page_view_header_id'] = (int)M('Pages') -> where(array('site_id' =>$tositeid, 'rid' => $v['page_view_header_id'])) -> getField('id');
				$v['page_view_footer_id'] = (int)M('Pages') -> where(array('site_id' =>$tositeid, 'rid' => $v['page_view_footer_id'])) -> getField('id');
				unset($v['id']);
				$pid1 = $this->data($v)->add();
			}
			return true;
		}
	}
}
